package com.cn.demo4.controller;

import com.alibaba.fastjson.JSONObject;
import com.cn.demo4.entity.UserEntity;
import com.cn.demo4.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author LXJ
 * date 2021-1-18
 */
@Controller
//地址映射
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService iUserService;
    @RequestMapping("findAll")
    public void findAll(HttpServletResponse resp) throws IOException {
        List<UserEntity> list = iUserService.findAll();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list",list);
        resp.getWriter().println(jsonObject);
    }

}
